package mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.example.bean.HomePostsInfo;
import org.example.bean.ReplyPostsInfo;

import java.util.List;

public interface HomePostsMapper {
    @Select("select * from homeposts where forumId=#{id}")
    List<HomePostsInfo> findHomePostsByForumsId(int id);
    @Insert("INSERT INTO homeposts VALUES(null,#{userId},#{forumId},#{homePostTitle},1,now(),#{homePostContexts})")
    void saveHomePosts(HomePostsInfo hpi);
    @Select("select * from homeposts where homePostId=#{id}")
    HomePostsInfo findHomePostById(int id);
    @Select("select * from replyposts where homepostid=#{id}")
    List<ReplyPostsInfo> findReplyPostsByHomePostId(int id);
    @Insert("insert into replyposts values(NULL,#{userId},#{replyPostContexts},NOW(),#{homePostId},1)")
    void saveReply(ReplyPostsInfo rpi);
}
